define([
	"UtilDir/util",
	"UtilDir/tool",
    "UtilDir/org/selectOrg",
    "UtilDir/searchBlock",
	"Date","DateCN", "css!DateCss",
	"EasyUI","EasyUI-lang"
    ],function(Util, Tool, SelectOrg, SearchBlock){

    var sysPath =  getServer() + "/static/app/cdqh/qhsystemcheck";

    var qhDrillOverviewFormHtml = sysPath + "/views/qhDrillOverviewForm.html";
    var qhDrillHistogramFormHtml = sysPath + "/views/qhDrillHistogramForm.html";
    var qhStandardPenetrationFormHtml = sysPath + "/views/qhStandardPenetrationForm.html";
    var qhSituShearWaveFormHtml = sysPath + "/views/qhSituShearWaveForm.html";
    var qhSoilDynamicFormHtml = sysPath + "/views/qhSoilDynamicForm.html";
    var qhSeismicFortificationFormHtml = sysPath + "/views/qhSeismicFortificationForm.html";
	var getQhCriteriaQueriesController = function(){
		return getServer() + "/qh/zfzxCriteriaQueries";
	};
	var getQhDrillOverviewController = function(){
		return getServer() + "/qh/qhDrillOverviews";
	};
	var getQhDrillHistogramController = function(){
		return getServer() + "/qh/qhDrillHistograms";
	};
	var getQhStandardPenetrationController = function(){
		return getServer() + "/qh/qhStandardPenetrations";
	};
	var getQhStandardPenetrationController = function(){
		return getServer() + "/qh/qhStandardPenetrations";
	};
	var getQhSituShearWaveController = function(){
		return getServer() + "/qh/qhSituShearWaves";
	};
	var getQhSoilDynamicController = function(){
		return getServer() + "/qh/qhSoilDynamics";
	};
	var getQhSeismicFortificationController = function(){
		return getServer() + "/qh/qhSeismicFortifications";
	};
	/**
	 * 页面初始化
	 */
	var init = function(){
        initSearchBlock();
        queryBtnBind();
        initcreateProvince();
		createQhDrillOverviewGrid();
		
	};
    var initcreateProvince = function () {
        var html = "";
        $("#citySelect").append(html);
        $("#areaSelect").append(html);
        $.ajax({
            url: "/divisions/root/subdivisions",
            contentType: "application/json",
            type: "get",
            success: function (data) {
                $.each(data, function (idx, item) {
                    html += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                });
                $("#provinceSelect").append(html);
            }
        });
        $("#provinceSelect").change(function () {
            var html = '<option value="" disabled selected style="display:none;">请选择</option>';
            $("#citySelect option").remove();
            $("#citySelect").append(html);
            $("#areaSelect option").remove();
            $("#areaSelect").append(html);
            var divisionId = $(this).find("option:selected").attr("exid");
            if ($(this).val() == "北京市" || $(this).val() == "天津市" || $(this).val() == "上海市" || $(this).val() == "重庆市") {
                $("#citySelect").append("<option value='" + $(this).val() + "' exid='" + divisionId + "'>" + $(this).val() + "</option>");
                return;
            }
            $.ajax({
                url: "/divisions/" + divisionId + "/subdivisions",
                contentType: "application/json",
                type: "get",
                success: function (data) {
                    $.each(data, function (idx, item) {
                        html += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                    });
                    $("#citySelect").append(html);
                }
            });
        });
        $("#citySelect").change(function () {
            if ($(this).val() == "") return;
            var html = '<option value="" disabled selected style="display:none;">请选择</option>';
            $("#areaSelect option").remove();
            $("#areaSelect").append(html);
            var divisionId = $(this).find("option:selected").attr("exid");
            $.ajax({
                url: "/divisions/" + divisionId + "/subdivisions",
                contentType: "application/json",
                type: "get",
                success: function (data) {
                    $.each(data, function (idx, item) {
                        html += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                    });
                    $("#areaSelect").append(html);
                }
            });
        });
    }
    var initcreateProvinceForm = function () {
        var html = "";
        $("#city").append(html);
        $("#area").append(html);
        $.ajax({
            url: "/divisions/root/subdivisions",
            contentType: "application/json",
            type: "get",
            success: function (data) {
                $.each(data, function (idx, item) {
                    html += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                });
                $("#province").append(html);
            }
        });
        $("#province").change(function () {
            var html = '<option value="" disabled selected style="display:none;">请选择</option>';
            $("#city option").remove();
            $("#city").append(html);
            $("#area option").remove();
            $("#area").append(html);
            var divisionId = $(this).find("option:selected").attr("exid");
            if ($(this).val() == "北京市" || $(this).val() == "天津市" || $(this).val() == "上海市" || $(this).val() == "重庆市") {
                $("#city").append("<option value='" + $(this).val() + "' exid='" + divisionId + "'>" + $(this).val() + "</option>");
                return;
            }
            $.ajax({
                url: "/divisions/" + divisionId + "/subdivisions",
                contentType: "application/json",
                type: "get",
                success: function (data) {
                    $.each(data, function (idx, item) {
                        html += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                    });
                    $("#city").append(html);
                }
            });
        });
        $("#city").change(function () {
            if ($(this).val() == "") return;
            var html = '<option value="" disabled selected style="display:none;">请选择</option>';
            $("#area option").remove();
            $("#area").append(html);
            var divisionId = $(this).find("option:selected").attr("exid");
            $.ajax({
                url: "/divisions/" + divisionId + "/subdivisions",
                contentType: "application/json",
                type: "get",
                success: function (data) {
                    $.each(data, function (idx, item) {
                        html += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                    });
                    $("#area").append(html);
                }
            });
        });
    }


	var initReportCompleteDateTimeDate = function() {
		$("#reportCompleteDate").datetimepicker({
			//设置使用语言：cn是自定义的中文版本，还可以扩展其他语言版本
			language : "cn",
			//输出格式化
			format : 'yyyy-mm-dd',
			//直接选择‘今天’
			todayBtn : true,
			//设置最精确的时间选择视图
			minView : 'month',
			//高亮当天日期
			todayHighlight : true,
			//显示“上午”“下午”
			showMeridian : true,
			//选择完毕后自动关闭
			autoclose : true
		});
	};

	var initConstructionCompleteDateTimeDate = function() {
		$("#constructionCompleteDate").datetimepicker({
			//设置使用语言：cn是自定义的中文版本，还可以扩展其他语言版本
			language : "cn",
			//输出格式化
			format : 'yyyy-mm-dd',
			//直接选择‘今天’
			todayBtn : true,
			//设置最精确的时间选择视图
			minView : 'month',
			//高亮当天日期
			todayHighlight : true,
			//显示“上午”“下午”
			showMeridian : true,
			//选择完毕后自动关闭
			autoclose : true
		});
	};
	var initCommencementDateTimeDate = function() {
		$("#commencementDate").datetimepicker({
			//设置使用语言：cn是自定义的中文版本，还可以扩展其他语言版本
			language : "cn",
			//输出格式化
			format : 'yyyy-mm-dd',
			//直接选择‘今天’
			todayBtn : true,
			//设置最精确的时间选择视图
			minView : 'month',
			//高亮当天日期
			todayHighlight : true,
			//显示“上午”“下午”
			showMeridian : true,
			//选择完毕后自动关闭
			autoclose : true
		});
	};
	var initCompletionDateTimeDate = function() {
		$("#completionDate").datetimepicker({
			//设置使用语言：cn是自定义的中文版本，还可以扩展其他语言版本
			language : "cn",
			//输出格式化
			format : 'yyyy-mm-dd',
			//直接选择‘今天’
			todayBtn : true,
			//设置最精确的时间选择视图
			minView : 'month',
			//高亮当天日期
			todayHighlight : true,
			//显示“上午”“下午”
			showMeridian : true,
			//选择完毕后自动关闭
			autoclose : true
		});
	};
	var initGageDateTimeDate = function() {
		$("#gageDate").datetimepicker({
			//设置使用语言：cn是自定义的中文版本，还可以扩展其他语言版本
			language : "cn",
			//输出格式化
			format : 'yyyy-mm-dd',
			//直接选择‘今天’
			todayBtn : true,
			//设置最精确的时间选择视图
			minView : 'month',
			//高亮当天日期
			todayHighlight : true,
			//显示“上午”“下午”
			showMeridian : true,
			//选择完毕后自动关闭
			autoclose : true
		});
	};

	var initSearchBlock = function(){
        SearchBlock.init("searchBlock");
        $("#qualityinspectionStatus").change(function () {
            if ($(this).val() == "2"||$(this).val() == "3"){
            	$("#systemCheck").attr('disabled',true);
            	$("#systemCheck").css("background","#007fff")
            }else{
            	$("#systemCheck").attr('disabled',false);
            }
            
        });
        require(["jquery", "Date", "DateCN", "css!DateCss"], function ($) {
            $("#complex1").datetimepicker({
                //设置使用语言：cn是自定义的中文版本，还可以扩展其他语言版本
                language: "cn",
                //输出格式化
                format: 'yyyy',
                //直接选择‘今天’
                todayBtn: true,
                weekStart: 1,
                // 设置最精确的时间选择视图
                startView: 4,
                //设置最精确的时间选择视图
                minView: 4,
//              minView: 'month',
                //高亮当天日期
                todayHighlight: true,
                //选择完毕后自动关闭
                autoclose: true
            });
            /* 删除按钮 */
            $("#complex_show1").on("click", function () {
                $('#complex1').datetimepicker('show');
            });
            /* 显示按钮 */
            $("#complex_del1").on("click", function () {
                $("#complex1").val("");
            });

            $("#complex2").datetimepicker({
                //设置使用语言：cn是自定义的中文版本，还可以扩展其他语言版本
                language: "cn",
                //输出格式化
                format: 'yyyy',
                weekStart: 1,
                // 设置最精确的时间选择视图
                startView: 4,
                //直接选择‘今天’
                todayBtn: true,
                //设置最精确的时间选择视图
                minView: 4,
                //minView: 'month',
                //高亮当天日期
                todayHighlight: true,
                //选择完毕后自动关闭
                autoclose: true
            });
            /* 删除按钮 */
            $("#complex_show2").on("click", function () {
                $('#complex2').datetimepicker('show');
            });
            /* 显示按钮 */
            $("#complex_del2").on("click", function () {
                $("#complex2").val("");
            });
        })
	};
	var queryBtnBind = function(){
		$("#complex1").change(function () {
            if ($("#complex1").val() != "" && $("#complex2").val() != "") {
                if ($("#complex1").val() > $("#complex2").val()) {
                    Util.alert("开始日期必须小于等于结束日期", function () {
                        $("#complex1").val("");
                        $("#complex2").val("");
                    });
                    return;
                }
            }
        });
        $("#complex2").change(function () {
            if ($("#complex1").val() != "" && $("#complex2").val() != "") {
                if ($("#complex1").val() > $("#complex2").val()) {
                    Util.alert("开始日期必须小于等于结束日期", function () {
                        $("#complex1").val("");
                        $("#complex2").val("");
                    });
                    return;
                }
            }
        });
        $("#drillDepthStart").change(function () {
            if ($("#drillDepthStart").val() != "" && $("#drillDepthEnd").val() != "") {
                if ($("#drillDepthStart").val() > $("#drillDepthEnd").val()) {
                    Util.alert("开始终孔深度必须小于等于结束终孔深度", function () {
                        $("#drillDepthStart").val("");
                        $("#drillDepthEnd").val("");
                    });
                    return;
                }
            }
        });
        $("#drillDepthEnd").change(function () {
            if ($("#drillDepthStart").val() != "" && $("#drillDepthEnd").val() != "") {
                if ($("#drillDepthStart").val() > $("#drillDepthEnd").val()) {
                    Util.alert("开始终孔深度必须小于等于结束终孔深度", function () {
                        $("#drillDepthStart").val("");
                        $("#drillDepthEnd").val("");
                    });
                    return;
                }
            }
        });
        $("#btnSearch").click(function () {
            createQhDrillOverviewGrid();
        });
        $("#systemCheck").click(function () {
            $.ajax({
                url:getQhDrillOverviewController() + "/queryQhDrillOverviewsNoPage",
                contentType:"application/json",
                type: "post",
                data:JSON.stringify({
                    reportName: $("#reportNameCondition").val(),
                    projectName: $("#projectNameCondition").val(),
                    province: $("#provinceSelect").val(),
                    city: $("#citySelect").val(),
                    area: $("#areaSelect").val(),
                    town: $("#town").val(),
                    drillCode: $("#drillCodeCondition").val(),
                    reviewStatus: $("#reviewStatusSelect").val(),
                    siteClass:$("#siteClass").val(),
                    poreFormingBegin: $("#complex1").val(),
                    poreFormingEnd: $("#complex2").val(),
                    drillDepthBegin: $("#drillDepthStart").val(),
                    drillDepthEnd: $("#drillDepthEnd").val()

                }),
                success: function(res) {
                    var ids = "";
                    for(var i = 0; i < res.data.length; ++i) {
                        ids += res.data[i].id + ",";
                    }

                    ids = ids.substr(0, ids.length - 1);
                    window.location.href = getQhCriteriaQueriesController() + "/exportFile/" + ids;
                }
            })
            // createQhDrillOverviewGrid();
        });
        $("#btnReset").click(function () {
            $("#provinceSelect").val("");
            $("#citySelect").val("");
            $("#areaSelect").val("");
            $("#town").val("");
            $("#reportNameCondition").val("");
			$("#projectNameCondition").val("");
			$("#drillCodeCondition").val("");
            $("#qualityinspectionResult").val("");
            $("#siteClass").val("");
            $("#complex1").val("");
        	$("#complex2").val("");
            $("#drillDepthStart").val("");
        	$("#drillDepthEnd").val("");
		});
	};
	var createQhDrillOverviewGrid= function() {
        $("#qhDrillOverviewGrid").datagrid({
//          url:getQhCriteriaQueriesController() + "/criteriaQuery",
			url:getQhDrillOverviewController() + "/queryQhDrillOverviews",
			method:"GET",
            fitColumns: true,
            autoRowHeight: false,
            columns:[[
//              {field:"ck",checkbox:true},
				{
					field:'reportName',
					title:'资料报告名称',
					width:'9%',
					align:'center',
					formatter:function(value,rowData,rowIndex){
								return '<a href="#" onclick="_editQhDrillOverview(\'' + rowData.id + "','" + rowData.qualityinspectionResult + '\');"> '+rowData.reportName+' </a> '
					}
				},				
				{
					field:'constructionCompleteDate',
					title:'勘察施工结束日期',
					width:'8%',
					sortable: true,
					align:'center',
				},
				{
					field:'province',
					title:'省',
					width:'7%',
					align:'center',
				},
				{
					field:'city',
					title:'市',
					width:'7%',
					align:'center',
				},
				{
					field:'area',
					title:'区（县）',
					width:'7%',
					align:'center',
				},
				{
					field:'town',
					title:'乡镇',
					width:'8%',
					align:'center',
				},
				{
					field:'projectName',
					title:'勘察工程名称',
					width:'9%',
					align:'center',
				},
				{
					field:'siteClass',
					title:'场地分类',
					width:'5%',
					align:'center',
				},
				{
					field:'drillCode',
					title:'钻孔编号',
					width:'7%',
					align:'center',
				},
				{
					field:'drillDepth',
					title:'终孔深度',
					width:'6%',
					sortable: true,
					align:'center',
				},
				{
					field:'longitude',
					title:'钻孔坐标经度值',
					width:'7%',
					align:'center',
				},
				{
					field:'latitude',
					title:'钻孔坐标纬度值',
					width:'7%',
					align:'center',
				},
				{
					field:'qualityinspectionStatus',
					title:'质检状态',
					width:'6%',
					align:'center',
					formatter: function (value) {
                        if (value == "0") {
                            return '未质检';
                        } else if (value == "1") {
                            return '已系统质检';
                        } else if (value == "2") {
                            return '已人工质检';
                        } else if (value == "3") {
                            return '已终检';
                        }
                    }
				},
				{
					field:'qualityinspectionResult',
					title:'质检结果',
					width:'7%',
					align:'center',
					formatter: function (value) {
                        if (value == "0") {
                            return '质检不通过';
                        } else if (value == "1") {
                            return '质检通过';
                        } 
                    }
				},
            ]],
            onLoadSuccess: function (data) {
            	var rows = $("#qhDrillOverviewGrid").datagrid("getRows"); //获取当前页的所有行
				var ids = "";
				$.each(rows, function (i, row) {
					ids += row.drillCode + ",";
				});
				ids = ids.substr(0, ids.length - 1);
				//console.log(ids);
				createQhDrillHistogramGrid(ids);
				createQhStandardPenetrationGrid(ids);
				createQhSituShearWaveGrid(ids);
				createQhSoilDynamicGrid(ids);
				createQhSeismicFortificationGrid(ids);
              	//console.log(data);
            },
            queryParams:{
                province: $("#provinceSelect").val(),
                city: $("#citySelect").val(),
                area: $("#areaSelect").val(),
                town: $("#town").val(),
				reportName: $("#reportNameCondition").val(),
				projectName: $("#projectNameCondition").val(),
				drillCode: $("#drillCodeCondition").val(),
				qualityinspectionResult: $("#qualityinspectionResult").val(),
                qualityinspectionStatus: $("#qualityinspectionStatus").val(),
                siteClass:$("#siteClass").val(),
                poreFormingBegin: $("#complex1").val(),
                poreFormingEnd: $("#complex2").val(),                
                drillDepthBegin: $("#drillDepthStart").val(),
                drillDepthEnd: $("#drillDepthEnd").val(),
            },
            pagination: true,
            pageSize: 10
        });
    };
	var createQhDrillHistogramGrid= function(ids) {
		debugger;
        $("#qhDrillHistogramGrid").datagrid({
            url:getQhDrillHistogramController() + "/queryQhDrillHistograms",
			method:"GET",
            fitColumns: true,
            autoRowHeight: false,
            columns:[[
//              {field:"ck",checkbox:true},
				{
					field:'projectName',
					title:'工程名称',
					width:'9%',
					align:'center',
					formatter:function(value,rowData,rowIndex){
							return '<a href="#" onclick="_editQhDrillHistogram(\'' + rowData.id + "','" + rowData.qualityinspectionResult + '\');"> '+rowData.projectName+' </a> '
					}
				},
				{
					field:'province',
					title:'省',
					width:'7%',
					align:'center',
				},
				{
					field:'city',
					title:'市',
					width:'7%',
					align:'center',
				},
				{
					field:'area',
					title:'区（县）',
					width:'8%',
					align:'center',
				},
				{
					field:'town',
					title:'乡镇',
					width:'9%',
					align:'center',
				},
				{
					field:'drillX',
					title:'钻孔坐标格网X值',
					width:'7%',
					align:'center',
				},
				{
					field:'drillY',
					title:'钻孔坐标格网Y值',
					width:'7%',
					align:'center',
				},
				{
					field:'drillCode',
					title:'钻孔编号',
					width:'7%',
					align:'center',
				},
				{
					field:'orificeElevation',
					title:'孔口高程（m）',
					width:'7%',
					align:'center',
				},
				{
					field:'orificeDiameter',
					title:'孔口直径',
					width:'7%',
					align:'center',
				},
				{
					field:'columnarDiagram',
					title:'比例尺为不小于1：500的柱状图示',
					width:'13%',
					align:'center',
				},
				{
					field:'qualityinspectionStatus',
					title:'质检状态',
					width:'6%',
					align:'center',
					formatter: function (value) {
                        if (value == "0") {
                            return '未质检';
                        } else if (value == "1") {
                            return '已系统质检';
                        } else if (value == "2") {
                            return '已人工质检';
                        } else if (value == "3") {
                            return '已终检';
                        }
                    }
				},
				{
					field:'qualityinspectionResult',
					title:'质检结果',
					width:'7%',
					align:'center',
					formatter: function (value) {
                        if (value == "0") {
                            return '质检不通过';
                        } else if (value == "1") {
                            return '质检通过';
                        } 
                    }
				},
            ]],
            onLoadSuccess: function (data) {

              	//console.log(data);
            },
            queryParams:{
               drillCodes:ids 
            },
            pagination: true,
            pageSize: 10
        });
    };
	var createQhStandardPenetrationGrid= function(ids) {
        $("#qhStandardPenetrationGrid").datagrid({
            url:getQhStandardPenetrationController() + "/queryQhStandardPenetrations",
			method:"GET",
            fitColumns: true,
            autoRowHeight: false,
            columns:[[
//              {field:"ck",checkbox:true},
				{
					field:'projectName',
					title:'勘察工程名称',
					width:'9%',
					align:'center',
					formatter:function(value,rowData,rowIndex){
								return '<a href="#" onclick="_editQhStandardPenetration(\'' + rowData.id + "','" + rowData.qualityinspectionResult + '\');"> '+rowData.projectName+' </a> '
					}
				},
				{
					field:'province',
					title:'省',
					width:'7%',
					align:'center',
				},
				{
					field:'city',
					title:'市',
					width:'7%',
					align:'center',
				},
				{
					field:'area',
					title:'区（县）',
					width:'8%',
					align:'center',
				},
				{
					field:'town',
					title:'乡镇',
					width:'8%',
					align:'center',
				},
				{
					field:'drillCode',
					title:'钻孔编号',
					width:'8%',
					align:'center',
				},
				{
					field:'serialNumber',
					title:'序号',
					width:'8%',
					align:'center',
				},
				{
					field:'geotechnicalType',
					title:'岩石类型',
					width:'8%',
					align:'center',
				},
				{
					field:'standardStartDepth',
					title:'标准贯入起始深度',
					width:'8%',
					sortable: true,
					align:'center',
				},
				{
					field:'standardEndDepth',
					title:'标准贯入结束深度',
					width:'8%',
					sortable: true,
					align:'center',
				},
				{
					field:'standardHammerNumber',
					title:'标准贯入锤击数',
					width:'8%',
					sortable: true,
					align:'center',
				},
				{
					field:'qualityinspectionStatus',
					title:'质检状态',
					width:'6%',
					align:'center',
					formatter: function (value) {
                        if (value == "0") {
                            return '未质检';
                        } else if (value == "1") {
                            return '已系统质检';
                        } else if (value == "2") {
                            return '已人工质检';
                        } else if (value == "3") {
                            return '已终检';
                        }
                    }
				},
				{
					field:'qualityinspectionResult',
					title:'质检结果',
					width:'7%',
					align:'center',
					formatter: function (value) {
                        if (value == "0") {
                            return '质检不通过';
                        } else if (value == "1") {
                            return '质检通过';
                        } 
                    }
				},
            ]],
            onLoadSuccess: function (data) {

              	//console.log(data);
            },
            queryParams:{
				drillCodes:ids
            },
            pagination: true,
            pageSize: 10
        });
    };
	var createQhSituShearWaveGrid= function(ids) {
        $("#qhSituShearWaveGrid").datagrid({
            url:getQhSituShearWaveController() + "/queryQhSituShearWaves",
			method:"GET",
            fitColumns: true,
            autoRowHeight: false,
            columns:[[
//              {field:"ck",checkbox:true},
				{
					field:'projectName',
					title:'勘察工程名称',
					width:'10%',
					align:'center',
					formatter:function(value,rowData,rowIndex){
								return '<a href="#" onclick="_editQhSituShearWave(\'' + rowData.id + "','" + rowData.qualityinspectionResult + '\');"> '+rowData.projectName+' </a> '
					}
				},
				{
					field:'province',
					title:'省',
					width:'8%',
					align:'center',
				},
				{
					field:'city',
					title:'市',
					width:'8%',
					align:'center',
				},
				{
					field:'area',
					title:'区（县）',
					width:'8%',
					align:'center',
				},
				{
					field:'town',
					title:'乡镇',
					width:'10%',
					align:'center',
				},
				{
					field:'drillCode',
					title:'钻孔编号',
					width:'10%',
					align:'center',
				},
				{
					field:'serialNumber',
					title:'序号',
					width:'10%',
					align:'center',
				},
				{
					field:'testDepth',
					title:'测试深度',
					width:'10%',
					sortable: true,
					align:'center',
				},
				{
					field:'measuredValue',
					title:'实测值',
					width:'10%',
					sortable: true,
					align:'center',
				},
				{
					field:'qualityinspectionStatus',
					title:'质检状态',
					width:'8%',
					align:'center',
					formatter: function (value) {
                        if (value == "0") {
                            return '未质检';
                        } else if (value == "1") {
                            return '已系统质检';
                        } else if (value == "2") {
                            return '已人工质检';
                        } else if (value == "3") {
                            return '已终检';
                        }
                    }
				},
				{
					field:'qualityinspectionResult',
					title:'质检结果',
					width:'8%',
					align:'center',
					formatter: function (value) {
                        if (value == "0") {
                            return '质检不通过';
                        } else if (value == "1") {
                            return '质检通过';
                        } 
                    }
				},
            ]],
            onLoadSuccess: function (data) {

              	//console.log(data);
            },
            queryParams:{
               	drillCodes:ids
            },
            pagination: true,
            pageSize: 10
        });
    };
	var createQhSoilDynamicGrid= function(ids) {
        $("#qhSoilDynamicGrid").datagrid({
            url:getQhSoilDynamicController() + "/queryQhSoilDynamics",
			method:"GET",
            fitColumns: true,
            autoRowHeight: false,
            columns:[[
//              {field:"ck",checkbox:true},
				{
					field:'projectName',
					title:'勘察工程名称',
					width:'9%',
					align:'center',
					formatter:function(value,rowData,rowIndex){
								return '<a href="#" onclick="_editQhSoilDynamic(\'' + rowData.id + "','" + rowData.qualityinspectionResult + '\');"> '+rowData.projectName+' </a> '
					}
				},
				{
					field:'province',
					title:'省',
					width:'7%',
					align:'center',
				},
				{
					field:'city',
					title:'市',
					width:'7%',
					align:'center',
				},
				{
					field:'area',
					title:'区（县）',
					width:'7%',
					align:'center',
				},
				{
					field:'town',
					title:'乡镇',
					width:'9%',
					align:'center',
				},
				{
					field:'drillCode',
					title:'钻孔编号',
					width:'8%',
					align:'center',
				},
				{
					field:'serialNumber',
					title:'序号',
					width:'7%',
					align:'center',
				},
				{
					field:'geotechnicalCode',
					title:'岩土样品编号',
					width:'8%',
					align:'center',
				},
				{
					field:'geotechnicalType',
					title:'岩土样品类型',
					width:'8%',
					align:'center',
				},
				{
					field:'geotechnicalStartDepth',
					title:'岩土样品起始深度',
					width:'8%',
					sortable: true,
					align:'center',
				},
				{
					field:'geotechnicalEndDepth',
					title:'岩土样品结束深度',
					width:'8%',
					sortable: true,
					align:'center',
				},
				{
					field:'qualityinspectionStatus',
					title:'质检状态',
					width:'7%',
					align:'center',
					formatter: function (value) {
                        if (value == "0") {
                            return '未质检';
                        } else if (value == "1") {
                            return '已系统质检';
                        } else if (value == "2") {
                            return '已人工质检';
                        } else if (value == "3") {
                            return '已终检';
                        }
                    }
				},
				{
					field:'qualityinspectionResult',
					title:'质检结果',
					width:'8%',
					align:'center',
					formatter: function (value) {
                        if (value == "0") {
                            return '质检不通过';
                        } else if (value == "1") {
                            return '质检通过';
                        } 
                    }
				},
            ]],
            onLoadSuccess: function (data) {

              	//console.log(data);
            },
            queryParams:{
                drillCodes:ids
            },
            pagination: true,
            pageSize: 10
        });
    };
	var createQhSeismicFortificationGrid= function(ids) {
        $("#qhSeismicFortificationGrid").datagrid({
            url:getQhSeismicFortificationController() + "/queryQhSeismicFortifications",
			method:"GET",
            fitColumns: true,
            autoRowHeight: false,
            columns:[[
//          	{field:"ck",checkbox:true},
				{
					field:'projectName',
					title:'勘察工程名称',
					width:'10%',
					align:'center',
					formatter:function(value,rowData,rowIndex){
						return '<a href="#" onclick="_editQhSeismicFortification(\'' + rowData.id + "','" + rowData.qualityinspectionResult + '\');"> '+rowData.projectName+' </a> '
					}
				},
				{
					field:'province',
					title:'省',
					width:'8%',
					align:'center',
				},
				{
					field:'city',
					title:'市',
					width:'8%',
					align:'center',
				},
				{
					field:'area',
					title:'区（县）',
					width:'8%',
					align:'center',
				},
				{
					field:'town',
					title:'乡镇',
					width:'10%',
					align:'center',
				},
				{
					field:'drillCode',
					title:'钻孔编号',
					width:'9%',
					align:'center',
				},
				{
					field:'exceedanceProbability',
					title:'超越概率',
					width:'8%',
					align:'center',
				},
				{
					field:'amaxGal',
					title:'Amax (gal)',
					width:'8%',
					align:'center',
				},
				{
					field:'betaM',
					title:'βm',
					width:'8%',
					align:'center',
				},
				{
					field:'alphaMax',
					title:'αmax',
					width:'8%',
					align:'center',
				},
				{
					field:'qualityinspectionStatus',
					title:'质检状态',
					width:'8%',
					align:'center',
					formatter: function (value) {						
                        if (value == "0") {
                            return '未质检';
                        } else if (value == "1") {
                            return '已系统质检';
                        } else if (value == "2") {
                            return '已人工质检';
                        } else if (value == "3") {
                            return '已终检';
                        }
                    }
				},
				{
					field:'qualityinspectionResult',
					title:'质检结果',
					width:'8%',
					align:'center',
					formatter: function (value) {
                        if (value == "0") {
                            return '质检不通过';
                        } else if (value == "1") {
                            return '质检通过';
                        } 
                    }
				},
            ]],
            queryParams:{
				drillCodes:ids
            },
            pagination: true,
            pageSize: 10
        });
    };
	var formValidator1 = function(){
		$("#qhDrillOverviewForm").validate({
			rules : {
				province : {
					required : true,
				},
				city : {
					required : true,
				},
				area : {
					required : true,
				},
				projectName : {
					required : true,
				},
				constructionInstitution : {
					required : true,
				},
				constructionPrincipal : {
					required : true,
				},
				constructionCompleteDate : {
					required : true,
				},
				constructionPlace : {
					required : true,
				},
				drillCode : {
					required : true,
				},
				drillDepth : {
					required : true,
				},
				longitude : {
					required : true,
				},
				latitude : {
					required : true,
				},
				drillX : {
					required : true,
				},
				drillY : {
					required : true,
				},
				elevation : {
					required : true,
				},
				stableWaterDepth : {
					required : true,
				},
			},
			messages : {
				province : {
					required : "省不允许为空!",
				},
				city : {
					required : "市不允许为空!",
				},
				area : {
					required : "区（县）不允许为空!",
				},
				projectName : {
					required : "勘察工程名称不允许为空!",
				},
				constructionInstitution : {
					required : "勘察施工单位名称不允许为空!",
				},
				constructionPrincipal : {
					required : "勘察施工单位负责人不允许为空!",
				},
				constructionCompleteDate : {
					required : "勘察施工结束日期不允许为空!",
				},
				constructionPlace : {
					required : "勘察施工地点不允许为空!",
				},
				drillCode : {
					required : "钻孔编号不允许为空!",
				},
				drillDepth : {
					required : "终孔深度不允许为空!",
				},
				longitude : {
					required : "钻孔坐标经度值不允许为空!",
				},
				latitude : {
					required : "钻孔坐标纬度值不允许为空!",
				},
				drillX : {
					required : "钻孔坐标格网X值不允许为空!",
				},
				drillY : {
					required : "钻孔坐标格网Y值不允许为空!",
				},
				elevation : {
					required : "地面高程不允许为空!",
				},
				stableWaterDepth : {
					required : "稳定水位深度不允许为空!",
				},
			}
		});
	};
	var formValidator2 = function(){
		$("#qhDrillHistogramForm").validate({
			rules : {
				projectName : {
					required : true,
				},
				drillCode : {
					required : true,
				},
				orificeElevation : {
					required : true,
				},
				orificeDiameter : {
					required : true,
				},
				drillX : {
					required : true,
				},
				drillY : {
					required : true,
				},
				province : {
					required : true,
				},
				city : {
					required : true,
				},
				area : {
					required : true,
				},
				commencementDate : {
					required : true,
				},
				completionDate : {
					required : true,
				},
				stableWaterDepth : {
					required : true,
				},
				gageDate : {
					required : true,
				},
				formationCode : {
					required : true,
				},
				formationCauseAge : {
					required : true,
				},
				bottomElevation : {
					required : true,
				},
				bottomDepth : {
					required : true,
				},
				layerThickness : {
					required : true,
				},
				columnarDiagram : {
					required : true,
				},
				geotechnicalName : {
					required : true,
				},
				geotechnicalCharacteristics : {
					required : true,
				},
				sampleDepthCode : {
					required : true,
				},
				standardPenetrationNum : {
					required : true,
				},
				standardPenetrationDepth : {
					required : true,
				},
				attachment : {
					required : true,
				},
			},
			messages : {
				projectName : {
					required : "工程名称不允许为空!",
				},
				drillCode : {
					required : "钻孔编号不允许为空!",
				},
				orificeElevation : {
					required : "孔口高程（m）不允许为空!",
				},
				orificeDiameter : {
					required : "孔口直径不允许为空!",
				},
				drillX : {
					required : "钻孔坐标格网X值不允许为空!",
				},
				drillY : {
					required : "钻孔坐标格网Y值不允许为空!",
				},
				province : {
					required : "省不允许为空!",
				},
				city : {
					required : "市不允许为空!",
				},
				area : {
					required : "区不允许为空!",
				},
				commencementDate : {
					required : "开工日期不允许为空!",
				},
				completionDate : {
					required : "竣工日期不允许为空!",
				},
				stableWaterDepth : {
					required : "稳定水位深度不允许为空!",
				},
				gageDate : {
					required : "测量水位日期不允许为空!",
				},
				formationCode : {
					required : "地层编号不允许为空!",
				},
				formationCauseAge : {
					required : "地层成因年代不允许为空!",
				},
				bottomElevation : {
					required : "层底高程不允许为空!",
				},
				bottomDepth : {
					required : "层底深度不允许为空!",
				},
				layerThickness : {
					required : "层厚不允许为空!",
				},
				columnarDiagram : {
					required : "比例尺为不小于1：500的柱状图示不允许为空!",
				},
				geotechnicalName : {
					required : "岩土名称不允许为空!",
				},
				geotechnicalCharacteristics : {
					required : "岩土特征不允许为空!",
				},
				sampleDepthCode : {
					required : "取样深度及编号不允许为空!",
				},
				standardPenetrationNum : {
					required : "标准贯入实验实测值不允许为空!",
				},
				standardPenetrationDepth : {
					required : "标准贯入实验实验深度不允许为空!",
				},
				attachment : {
					required : "附件不允许为空!",
				},
			}
		});
	};
	var formValidator3 = function(){
		$("#qhStandardPenetrationForm").validate({
			rules : {
				projectName : {
					required : true,
				},
				drillCode : {
					required : true,
				},
				serialNumber : {
					required : true,
				},
				province : {
					required : true,
				},
				city : {
					required : true,
				},
				area : {
					required : true,
				},
				geotechnicalType : {
					required : true,
				},
				standardStartDepth : {
					required : true,
				},
				standardEndDepth : {
					required : true,
				},
				standardHammerNumber : {
					required : true,
				},
			},
			messages : {
				projectName : {
					required : "勘察工程名称不允许为空!",
				},
				drillCode : {
					required : "钻孔编号不允许为空!",
				},
				serialNumber : {
					required : "序号不允许为空!",
				},
				province : {
					required : "省不允许为空!",
				},
				city : {
					required : "市不允许为空!",
				},
				area : {
					required : "区（县）不允许为空!",
				},
				geotechnicalType : {
					required : "岩石类型不允许为空!",
				},
				standardStartDepth : {
					required : "标准贯入起始深度不允许为空!",
				},
				standardEndDepth : {
					required : "标准贯入结束深度不允许为空!",
				},
				standardHammerNumber : {
					required : "标准贯入锤击数不允许为空!",
				},
			}
		});
	};
	var formValidator4 = function(){
		$("#qhSituShearWaveForm").validate({
			rules : {
				projectName : {
					required : true,
				},
				province : {
					required : true,
				},
				city : {
					required : true,
				},
				area : {
					required : true,
				},
				drillCode : {
					required : true,
				},
				serialNumber : {
					required : true,
				},
				testDepth : {
					required : true,
				},
				measuredValue : {
					required : true,
				},
			},
			messages : {
				projectName : {
					required : "勘察工程名称不允许为空!",
				},
				province : {
					required : "省不允许为空!",
				},
				city : {
					required : "市不允许为空!",
				},
				area : {
					required : "区（县）不允许为空!",
				},
				drillCode : {
					required : "钻孔编号不允许为空!",
				},
				serialNumber : {
					required : "序号不允许为空!",
				},
				testDepth : {
					required : "测试深度不允许为空!",
				},
				measuredValue : {
					required : "实测值不允许为空!",
				},
			}
		});
	};
	var formValidator5 = function(){
		$("#qhSoilDynamicForm").validate({
			rules : {
				projectName : {
					required : true,
				},
				province : {
					required : true,
				},
				city : {
					required : true,
				},
				area : {
					required : true,
				},
				drillCode : {
					required : true,
				},
				serialNumber : {
					required : true,
				},
				geotechnicalCode : {
					required : true,
				},
				geotechnicalType : {
					required : true,
				},
				geotechnicalStartDepth : {
					required : true,
				},
				geotechnicalEndDepth : {
					required : true,
				},
				modulusShearStrain005 : {
					required : true,
				},
				modulusShearStrain010 : {
					required : true,
				},
				modulusShearStrain050 : {
					required : true,
				},
				modulusShearStrain100 : {
					required : true,
				},
				modulusShearStrain500 : {
					required : true,
				},
				modulusShearStrain1000 : {
					required : true,
				},
				modulusShearStrain5000 : {
					required : true,
				},
				modulusShearStrain10000 : {
					required : true,
				},
				dampShearStrain005 : {
					required : true,
				},
				dampShearStrain010 : {
					required : true,
				},
				dampShearStrain050 : {
					required : true,
				},
				dampShearStrain100 : {
					required : true,
				},
				dampShearStrain500 : {
					required : true,
				},
				dampShearStrain1000 : {
					required : true,
				},
				dampShearStrain5000 : {
					required : true,
				},
				dampShearStrain10000 : {
					required : true,
				},
			},
			messages : {
				projectName : {
					required : "勘察工程名称不允许为空!",
				},
				province : {
					required : "省不允许为空!",
				},
				city : {
					required : "市不允许为空!",
				},
				area : {
					required : "区不允许为空!",
				},
				drillCode : {
					required : "钻孔编号不允许为空!",
				},
				serialNumber : {
					required : "序号不允许为空!",
				},
				geotechnicalCode : {
					required : "岩土样品编号不允许为空!",
				},
				geotechnicalType : {
					required : "岩土样品类型不允许为空!",
				},
				geotechnicalStartDepth : {
					required : "岩土样品起始深度不允许为空!",
				},
				geotechnicalEndDepth : {
					required : "岩土样品结束深度不允许为空!",
				},
				modulusShearStrain005 : {
					required : "模量比(G/Gmax)剪应变(γ)（10-4×0.05)不允许为空!",
				},
				modulusShearStrain010 : {
					required : "模量比(G/Gmax)剪应变(γ)（10-4×0.10)不允许为空!",
				},
				modulusShearStrain050 : {
					required : "模量比(G/Gmax)剪应变(γ)（10-4×0.50)不允许为空!",
				},
				modulusShearStrain100 : {
					required : "模量比(G/Gmax)剪应变(γ)（10-4×1.00)不允许为空!",
				},
				modulusShearStrain500 : {
					required : "模量比(G/Gmax)剪应变(γ)（10-4×5.00)不允许为空!",
				},
				modulusShearStrain1000 : {
					required : "模量比(G/Gmax)剪应变(γ)（10-4×10.00)不允许为空!",
				},
				modulusShearStrain5000 : {
					required : "模量比(G/Gmax)剪应变(γ)（10-4×50.00)不允许为空!",
				},
				modulusShearStrain10000 : {
					required : "模量比(G/Gmax)剪应变(γ)（10-4×100.00)不允许为空!",
				},
				dampShearStrain005 : {
					required : "阻尼比(λ)剪应变(γ)（10-4×0.05)不允许为空!",
				},
				dampShearStrain010 : {
					required : "阻尼比(λ)剪应变(γ)（10-4×0.10)不允许为空!",
				},
				dampShearStrain050 : {
					required : "阻尼比(λ)剪应变(γ)（10-4×0.50)不允许为空!",
				},
				dampShearStrain100 : {
					required : "阻尼比(λ)剪应变(γ)（10-4×1.00)不允许为空!",
				},
				dampShearStrain500 : {
					required : "阻尼比(λ)剪应变(γ)（10-4×5.00)不允许为空!",
				},
				dampShearStrain1000 : {
					required : "阻尼比(λ)剪应变(γ)（10-4×10.00)不允许为空!",
				},
				dampShearStrain5000 : {
					required : "阻尼比(λ)剪应变(γ)（10-4×50.00)不允许为空!",
				},
				dampShearStrain10000 : {
					required : "阻尼比(λ)剪应变(γ)（10-4×100.00)不允许为空!",
				},
			}
		});
	};
	var formValidator6 = function(){
		$("#qhSeismicFortificationForm").validate({
			rules : {
				projectName : {
					required : true,
				},
				drillCode : {
					required : true,
				},
				province : {
					required : true,
				},
				city : {
					required : true,
				},
				area : {
					required : true,
				},
				exceedanceProbability : {
					required : true,
				},
				aMaxGal : {
					required : true,
				},
				βm : {
					required : true,
				},
				αMax : {
					required : true,
				},
				t1Sec : {
					required : true,
				},
				t2Sec : {
					required : true,
				},
				t3Sec : {
					required : true,
				},
				γ : {
					required : true,
				},
			},
			messages : {
				projectName : {
					required : "勘察工程名称不允许为空!",
				},
				drillCode : {
					required : "钻孔编号不允许为空!",
				},
				province : {
					required : "省不允许为空!",
				},
				city : {
					required : "市不允许为空!",
				},
				area : {
					required : "区不允许为空!",
				},
				exceedanceProbability : {
					required : "超越概率不允许为空!",
				},
				aMaxGal : {
					required : "Amax (gal)不允许为空!",
				},
				βm : {
					required : "βm不允许为空!",
				},
				αMax : {
					required : "αmax不允许为空!",
				},
				t1Sec : {
					required : "T1 (sec)不允许为空!",
				},
				t2Sec : {
					required : "T2 (sec)不允许为空!",
				},
				t3Sec : {
					required : "T3 (sec)不允许为空!",
				},
				γ : {
					required : "γ不允许为空!",
				},
			}
		});
	};
	var getQhDrillOverview = function(id,result){
		$.ajax({
			url: getQhDrillOverviewController() + "/"+id,
			type: "get",
			success: function (data) {
				if(result == "0"){
					$('#commentsArea').show();
				}
				editProvince(data.province, data.city, data.area);
				Tool.deserialize("qhDrillOverviewForm", data);
			}
		});
	};
	var getQhDrillHistogram = function(id,result){
		debugger
		$.ajax({
			url: getQhDrillHistogramController() + "/"+id,
			type: "get",
			success: function (data) {
				if(result == "0"){
					$('#commentsArea').show();
				}
				editProvince(data.province, data.city, data.area);
				viewFileUpload(data.attachment);
				Tool.deserialize("qhDrillHistogramForm", data);
			}
		});
	};
	var getQhStandardPenetration = function(id,result){
		$.ajax({
			url: getQhStandardPenetrationController() + "/"+id,
			type: "get",
			success: function (data) {
				if(result == "0"){
					$('#commentsArea').show();
				}
				editProvince(data.province, data.city, data.area);
				Tool.deserialize("qhStandardPenetrationForm", data);
			}
		});
	};
	var getQhSituShearWave = function(id,result){
		$.ajax({
			url: getQhSituShearWaveController() + "/"+id,
			type: "get",
			success: function (data) {
				if(result == "0"){
					$('#commentsArea').show();
				}
				editProvince(data.province, data.city, data.area);
				Tool.deserialize("qhSituShearWaveForm", data);
			}
		});
	};
	var getQhSoilDynamic = function(id,result){
		$.ajax({
			url: getQhSoilDynamicController() + "/"+id,
			type: "get",
			success: function (data) {
				if(result == "0"){
					$('#commentsArea').show();
				}
				editProvince(data.province, data.city, data.area);
				Tool.deserialize("qhSoilDynamicForm", data);
			}
		});
	};
	var getQhSeismicFortification = function(id,result){
		$.ajax({
			url: getQhSeismicFortificationController() + "/"+id,
			type: "get",
			success: function (data) {
				if(result == "0"){
					$('#commentsArea').show();
				}
				editProvince(data.province, data.city, data.area);
				Tool.deserialize("qhSeismicFortificationForm", data);
			}
		});
	};
    var editProvince = function (Province, City, Area) {
        debugger;
        var html = "";
        $("#city").append(html);
        $("#area").append(html);
        $.ajax({
            url: "/divisions/root/subdivisions",
            contentType: "application/json",
            type: "get",
            success: function (data) {
                $.each(data, function (idx, item) {
                    if (item.divisionName == Province) {
                        debugger;
                        var divisionId = item.divisionId;
                        var htmlCity = '';
                        if (Province == "北京市" || Province == "天津市" || Province == "上海市" || Province == "重庆市") {
                            $("#city").append("<option value='" + Province + "' exid='" + divisionId + "'>" + Province + "</option>");
                            $('#city').val(City);
                            var htmlArea = '';
                            $.ajax({
                                url: "/divisions/" + divisionId + "/subdivisions",
                                contentType: "application/json",
                                type: "get",
                                success: function (data) {
                                    $.each(data, function (idx, item) {
                                        htmlArea += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                                    });
                                    $("#area").append(htmlArea);
                                    $('#area').val(Area);
                                }
                            });

                        } else {
                            $.ajax({
                                url: "/divisions/" + divisionId + "/subdivisions",
                                contentType: "application/json",
                                type: "get",
                                success: function (data) {
                                    debugger;
                                    $.each(data, function (idx, item) {
                                        if (item.divisionName == City) {
                                            var divisionId = item.divisionId;
                                            var htmlArea = '';
                                            $.ajax({
                                                url: "/divisions/" + divisionId + "/subdivisions",
                                                contentType: "application/json",
                                                type: "get",
                                                success: function (data) {
                                                    $.each(data, function (idx, item) {
                                                        htmlArea += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                                                    });
                                                    $("#area").append(htmlArea);
                                                    $('#area').val(Area);
                                                }
                                            });
                                        }
                                        htmlCity += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                                    });
                                    $("#city").append(htmlCity);
                                    $('#city').val(City);
                                }
                            });
                        }
                    }
                    html += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                });
                $("#province").append(html);
                $('#province').val(Province);
            }
        });
        $("#province").change(function () {
            var html = '<option value="" disabled selected style="display:none;">请选择</option>';
            $("#city option").remove();
            $("#city").append(html);
            $("#area option").remove();
            $("#area").append(html);
            var divisionId = $(this).find("option:selected").attr("exid");
            if ($(this).val() == "北京市" || $(this).val() == "天津市" || $(this).val() == "上海市" || $(this).val() == "重庆市") {
                $("#city").append("<option value='" + $(this).val() + "' exid='" + divisionId + "'>" + $(this).val() + "</option>");
                return;
            }
            $.ajax({
                url: "/divisions/" + divisionId + "/subdivisions",
                contentType: "application/json",
                type: "get",
                success: function (data) {
                    $.each(data, function (idx, item) {
                        html += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                    });
                    $("#city").append(html);
                }
            });
        });
        $("#city").change(function () {
            if ($(this).val() == "") return;
            var html = '<option value="" disabled selected style="display:none;">请选择</option>';
            $("#area option").remove();
            $("#area").append(html);
            var divisionId = $(this).find("option:selected").attr("exid");
            $.ajax({
                url: "/divisions/" + divisionId + "/subdivisions",
                contentType: "application/json",
                type: "get",
                success: function (data) {
                    $.each(data, function (idx, item) {
                        html += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                    });
                    $("#area").append(html);
                }
            });
        });
    };
    var viewFileUpload = function (fileData) {
        require(['UtilDir/fileupload/multiFileUpload'], function (MFU) {
            var attachIdData = "";
            var attachId = "";
            var fileArray = fileData.split(',');
            if (fileData.length != 0) {
                attachIdData = fileData.split(',');
            }
            var settings = {
                placeAt: "multiFileUpload",
                /*
	            1.0.2版本新增
	            extendColumn:[
	                {name:"文件分类",filed:"category",format:function(file){return file.name}},
	                {name:"备注",filed:"remark",format:function(file){return '机密'}}
	            ],*/
                data: attachIdData,
                onUploadSuccess: function (file) {
                    attachId += file.attachId + ",";
                    if (fileData.length == 0) {
                        $("#attachment").val(attachId.substr(0, attachId.length - 1));
                    } else {
                        $("#attachment").val(fileData + "," + attachId.substr(0, attachId.length - 1));
                    }

                },
                onDeleteSavedFile: function (file) {
                    var index = fileArray.indexOf(file.attachId);
                    fileArray.splice(index, 1);
                    $("#attachment").val(fileArray.toString());
                }
            };
            var MFUpload = MFU.init(settings);

        });
    };

	window._editQhDrillOverview = function(qhDrillOverviewId,result) {
		var slidebar = Util.slidebar({
			url: qhDrillOverviewFormHtml,
			width: "900px",
			cache: false,
			close : true,
			afterLoad: function () {
				initReportCompleteDateTimeDate();
				initConstructionCompleteDateTimeDate();
				formValidator1();
				getQhDrillOverview(qhDrillOverviewId,result);
				$("#saveBtn").on("click", function () {
					if($("#qhDrillOverviewForm").valid()){
						var data = Tool.serialize("qhDrillOverviewForm");
						$.ajax({
							url: getQhDrillOverviewController(),
                            contentType:"application/json",
                            data: JSON.stringify(data),
							type: "put",
							success: function (data) {
								Util.alert(data.message);
								slidebar.close();
								createQhDrillOverviewGrid();
							}
						});
					}
				});
			}
		});
	};
	window._editQhDrillHistogram = function(qhDrillHistogramId,result) {
		var slidebar = Util.slidebar({
			url: qhDrillHistogramFormHtml,
			width: "900px",
			cache: false,
			close : true,
			afterLoad: function () {
				initCommencementDateTimeDate();
				initCompletionDateTimeDate();
				initGageDateTimeDate();
				formValidator2();
				getQhDrillHistogram(qhDrillHistogramId,result);
				$("#saveBtn").on("click", function () {
					if($("#qhDrillHistogramForm").valid()){
						var data = Tool.serialize("qhDrillHistogramForm");
						$.ajax({
							url: getQhDrillHistogramController(),
                            contentType:"application/json",
                            data: JSON.stringify(data),
							type: "put",
							success: function (data) {
								Util.alert(data.message);
								slidebar.close();
								createQhDrillHistogramGrid();
							}
						});
					}
				});
			}
		});
	};
	window._editQhStandardPenetration = function(qhStandardPenetrationId,result) {
		var slidebar = Util.slidebar({
			url: qhStandardPenetrationFormHtml,
			width: "900px",
			cache: false,
			close : true,
			afterLoad: function () {
				formValidator3();
				getQhStandardPenetration(qhStandardPenetrationId,result);
				$("#saveBtn").on("click", function () {
					if($("#qhStandardPenetrationForm").valid()){
						var data = Tool.serialize("qhStandardPenetrationForm");
						$.ajax({
							url: getQhStandardPenetrationController(),
                            contentType:"application/json",
                            data: JSON.stringify(data),
							type: "put",
							success: function (data) {
								Util.alert(data.message);
								slidebar.close();
								createQhStandardPenetrationGrid();
							}
						});
					}
				});
			}
		});
	};
	window._editQhSituShearWave = function(qhSituShearWaveId,result) {
		var slidebar = Util.slidebar({
			url: qhSituShearWaveFormHtml,
			width: "800px",
			cache: false,
			close : true,
			afterLoad: function () {
				formValidator4();
				getQhSituShearWave(qhSituShearWaveId,result);
				$("#saveBtn").on("click", function () {
					if($("#qhSituShearWaveForm").valid()){
						var data = Tool.serialize("qhSituShearWaveForm");
						$.ajax({
							url: getQhSituShearWaveController(),
                            contentType:"application/json",
                            data: JSON.stringify(data),
							type: "put",
							success: function (data) {
								Util.alert(data.message);
								slidebar.close();
								createQhSituShearWaveGrid();
							}
						});
					}
				});
			}
		});
	};
	window._editQhSoilDynamic = function(qhSoilDynamicId,result) {
		var slidebar = Util.slidebar({
			url: qhSoilDynamicFormHtml,
			width: "900px",
			cache: false,
			close : true,
			afterLoad: function () {
				formValidator5();
				getQhSoilDynamic(qhSoilDynamicId,result);
				$("#saveBtn").on("click", function () {
					if($("#qhSoilDynamicForm").valid()){
						var data = Tool.serialize("qhSoilDynamicForm");
						$.ajax({
							url: getQhSoilDynamicController(),
                            contentType:"application/json",
                            data: JSON.stringify(data),
							type: "put",
							success: function (data) {
								Util.alert(data.message);
								slidebar.close();
								createQhSoilDynamicGrid();
							}
						});
					}
				});
			}
		});
	};
	window._editQhSeismicFortification = function(qhSeismicFortificationId,result) {
		var slidebar = Util.slidebar({
			url: qhSeismicFortificationFormHtml,
			width: "800px",
			cache: false,
			close : true,
			afterLoad: function () {
				formValidator6();
				getQhSeismicFortification(qhSeismicFortificationId,result);
				$("#saveBtn").on("click", function () {
					if($("#qhSeismicFortificationForm").valid()){
						var data = Tool.serialize("qhSeismicFortificationForm");
						$.ajax({
							url: getQhSeismicFortificationController(),
                            contentType:"application/json",
                            data: JSON.stringify(data),
							type: "put",
							success: function (data) {
								Util.alert(data.message);
								slidebar.close();
								createQhSeismicFortificationGrid();
							}
						});
					}
				});
			}
		});
	};
	return {
		init:init
	};
});
